unit TankData;

{$mode objfpc}{$H+}

//========================================================================================
//
// Unit : TankData.pas
//
// Description :
//
// Called By : ApplicationSettings : frmSettings.ReadSettingsFile
//                                   frmSettings.WriteSettingsFile
//
// Calls : HUtils : ErrorMessageDlgOk
//                  ValidDirectoryCharacter
//                  ValidRealStr
//
// Ver. : 1.0.0
//
// Date : 1 Nov 2015
//
//========================================================================================

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Buttons,
  StdCtrls, ExtCtrls,
  // Application units
  HUtils;


type


  { TfrmTankData }

  TfrmTankData = class(TForm)
    bbtCancel: TBitBtn;
    bbtOK: TBitBtn;
    bbtHelp: TBitBtn;
    cbxTankType: TComboBox;
    cbxLengthUnits: TComboBox;
    cbxTemperatureUnits: TComboBox;
    cbxVolumeUnits: TComboBox;
    edtWidth: TEdit;
    edtDepth: TEdit;
    edtHeight: TEdit;
    edtVolume: TEdit;
    edtTankName: TEdit;
    gbxTankType: TGroupBox;
    gbxMeasurements: TGroupBox;
    gbxSize: TGroupBox;
    stxEnterTankName: TStaticText;
    stxWidth: TStaticText;
    stxDepth: TStaticText;
    stxHeight: TStaticText;
    stxVolume: TStaticText;
    stxVolumeUnits: TStaticText;
    stxTemperatureUnits: TStaticText;
    stxLengthUnits: TStaticText;
    stxSelectTankType: TStaticText;
    procedure bbtCancelClick(Sender: TObject);
    procedure bbtHelpClick(Sender: TObject);
    procedure bbtOKClick(Sender: TObject);
    procedure edtTankNameKeyPress(Sender: TObject; var Key: char);
    procedure edtWidthKeyPress(Sender: TObject; var Key: char);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
         // Default Values
/
         // Current Values
**    fTankName : string;
**    fTankType : tTankType;
**    fTankLengthUnit : tLengthUnit;
**    fTankTemperatureUnit : tTemperatureUnit;
**    fTankVolumeUnit : tVolumeUnit;
**    fTankWidth : real;
**    fTankDepth : real;
**    fTankHeight : real;
**    fTankVolume : real;

         // Current Private routines
//    procedure SelectTankType;
//    procedure SelectLengthUnit;
//    procedure SelectTemperatureUnit;
//    procedure SelectVolumeUnit;

  public
    { public declarations }
    const
  
         // Default Public Routines




    //  Current Public routines
//    function GetTankName: string;
//    procedure SetTankName (TankName: string);
//    function GetTankType: tTankType;
//    function GetTankTypeStr: string;
//    procedure SetTankType (TankType:tTankType);
//    procedure SetTankTypeFromStr (TankType:string);

//    function GetLengthUnit: tLengthUnit;
//    function GetLengthUnitStr: string;
//    procedure SetLengthUnit (LengthUnit:tLengthUnit);
//    procedure SetLengthUnitFromStr (strLengthUnit:string);

//    function GetTemperatureUnit: tTemperatureUnit;
//    function GetTemperatureUnitStr: string;
//    procedure SetTemperatureUnit (TemperatureUnit:tTemperatureUnit);
//    procedure SetTemperatureUnitFromStr (TemperatureUnit:string);

//    function GetVolumeUnit: tVolumeUnit;
//    function GetVolumeUnitStr: string;
//    procedure SetVolumeUnit (VolumeUnit:tVolumeUnit);
//    procedure SetVolumeUnitFromStr (VolumeUnit:string);

//    function GetTankWidth: real;
//    function GetTankWidthStr: string;
//    procedure SetTankWidth ( TankWidth : real );
//    procedure SetTankWidthFromStr (VolumeUnit:string);

//    function GetTankDepth: real;
//    function GetTankDepthStr: string;
//    procedure SetTankDepth ( TankDepth : real );
//    procedure SetTankDepthFromStr (TankDepth:string);

//    function GetTankHeight: real;
//    function GetTankHeightStr: string;
//    procedure SetTankHeight ( TankHeight : real );
//    procedure SetTankHeightFromStr (TankHeight:string);

//    function GetTankVolume: real;
//    function GetTankVolumeStr: string;
//    procedure SetTankVolume ( TankVolume : real );
//    procedure SetTankVolumeFromStr (TankVolume:string);

//    procedure CreateNewTank;

  published
             //  Default Properties

     //  Current Properties
//     property TankName: string read GEtTankName write SetTankName;
//     property TankType: tTankType read GetTankType
//                                        write SetTankType;
//     property LengthUnit: tLengthUnit read GetLengthUnit
//                                        write SetLengthUnit;
//     property TemperatureUnit: tTemperatureUnit read GetTemperatureUnit
//                                        write SetTemperatureUnit;
//     property VolumeUnit: tVolumeUnit read GetVolumeUnit
//                                        write SetVolumeUnit;
//     property TankWidth: real read GetTankWidth
//                                      write SetTankWidth;
//     property TankDepth: real read GetTankDepth
//                              write SetTankDepth;
//     property TankHeight: real read GetTankHeight
//                              write SetTankHeight;
//     property TankVolume: real read GetTankVolume
//                               write SetTankVolume;
  end;// TfrmTankData

var
  frmTankData: TfrmTankData;

implementation

{$R *.lfm}

const
  // Property Constants
//  cbytMinTankNameLength = 1;
//  cbytMaxTankNameLength = 20;

//  cbytMinWidthLength = 1;
//  cbytMaxWidthLength = 6;
//  cfltMinWidthValueInches = 5.0;
//  cfltMaxWidthValueInches = 120.0;
//  cfltMinWidthValueCM = 13.0;
//  cfltMaxWidthValueCM = 305;
//  cstrWidthFormat = '##0.00';

//  cbytMinDepthLength = 1;
//  cbytMaxDepthLength = 5;
//  cfltMinDepthValueInches = 1.0;
//  cfltMaxDepthValueInches = 6.0;
//  cfltMinDepthValueCM = 2.5;
//  cfltMaxDepthValueCM = 6.4;
//  cstrDepthFormat = '##0.00';

//  cbytMinHeightLength = 1;
//  cbytMaxHeightLength = 5;
//  cfltMinHeightValueInches = 6.0;
//  cfltMaxHeightValueInches = 96.0;
//  cfltMinHeightValueCM = 15.5;
//  cfltMaxHeightValueCM = 244.0;
//  cstrHeightFormat = '##0.00';

//  cbytMinVolumeLength = 1;
//  cbytMaxVolumeLength = 5;
//  cfltMinVolumeValueInches = 6.0;
//  cfltMaxVolumeValueInches = 96.0;
//  cfltMinVolumeValueCM = 15.5;
//  cfltMaxVolumeValueCM = 244.0;

var

  // Property VAriables
  // vttTankType : tTankType;
   //   vttLengthUnit : tLengthUnit;
   //   vttTemperatureUnit : tTemperatureUnit;
   //   vttVolumeUnit : tVolumeUnit;

//========================================================================================
//          PRIVATE ROUTINES
//========================================================================================
{procedure TfrmTankData.SelectTankType;
begin
  cbxTankType.ItemIndex := ord(fTankType);
end;// procedure SelectTankType; }

//========================================================================================
{procedure TfrmTankData.SelectLengthUnit;
begin
  cbxLengthUnits.ItemIndex := ord(fTankLengthUnit);
end;// procedure TfrmTankData.SelectLengthUnit; }

//========================================================================================
{procedure TfrmTankData.SelectTemperatureUnit;
begin
  cbxTemperatureUnits.ItemIndex := ord(fTankTemperatureUnit);
end;// procedure TfrmTankData.SelectTemperatureUnit;  }

//========================================================================================
{procedure TfrmTankData.SelectVolumeUnit;
begin
  cbxVolumeUnits.ItemIndex := ord(fTankVolumeUnit);
end;// procedure TfrmTankData.SelectVolumeUnit; }

//========================================================================================
//          PUBLIC ROUTINES
//========================================================================================

//========================================================================================
//          PUBLISHED ROUTINES
//========================================================================================

//========================================================================================
//          PROPERTY ROUTINES
//========================================================================================

//============================
//     Default Data Routines
//============================
//============================
//     Current Routines
//============================

{function TfrmTankData.GetTankName: string;
begin
  Result := fTankName;
end;  }

//----------------------------------------------------------------------------------------
{procedure TfrmTankData.SetTankName (TankName: string);
begin
  fTankName := TankName;
end;  }

//========================================================================================
{function TfrmTankData.GetTankType: tTankType;
begin
  Result := fTankType;
end;// function GetTankType  }

//----------------------------------------------------------------------------------------
{function TfrmTankData.GetTankTypeStr: string;
begin
  Result := TankTypeArray[ord(frmTankData.DefaultTankType)];
end;// function GetTankTypeStr }

//----------------------------------------------------------------------------------------
{procedure TfrmTankData.SetTankType (TankType:tTankType);
begin
  fTankType := TankType;
end;// procedure SetTankType }

//----------------------------------------------------------------------------------------
{procedure TfrmTankData.SetTankTypeFromStr (TankType:string);
begin
  case TankType of
    'ttFreshWater' : fTankType := ttFreshWater;
    'ttFO' : fTankType := ttFO;
    'ttFOWLR' : fTankType := ttFOWLR;
    'ttReef' : fTankType := ttReef;
    'ttOther' : fTankType := ttOther;
  end;// case TankType
end;// procedure SetDefaultTankTypeFromStr  }

//========================================================================================
{function TfrmTankData.GetLengthUnit: tLengthUnit;
begin
  Result := fTankLengthUnit;
end;// function GetLengthUnit  }

//----------------------------------------------------------------------------------------
{function TfrmTankData.GetLengthUnitStr: string;
begin
  case LengthUnit of
    tlInches : Result := 'tlInches';
    tlCM : Result := 'tlCM';
  end;// case LengthUnit
end;// function GetLengthUnitFromStr  }

//----------------------------------------------------------------------------------------
{procedure TfrmTankData.SetLengthUnit (LengthUnit:tLengthUnit);
begin
  fTankLengthUnit := LengthUnit;
end;// procedure SetLengthUnit  }

//----------------------------------------------------------------------------------------
{procedure TfrmTankData.SetLengthUnitFromStr(strLengthUnit:string);
begin
{  case LengthUnit of
    'tlInches' : fLengthUnit := tlInches;
    'tlCM' : fLengthUnit := tlCM;
  end;// case LengthUnit }
end;// procedure SetLengthUnitFromStr  }

//========================================================================================
{function TfrmTankData.GetTemperatureUnit: tTemperatureUnit;
begin
  Result := fTankTemperatureUnit;
end;// function GetTemperatureUnit   }

//----------------------------------------------------------------------------------------
{function TfrmTankData.GetTemperatureUnitStr: string;
begin

  Result := 'Degrees F';
{  case TemperatureUnit of
    tpDegF : Result := 'tpDegF';
    tpDegC : Result := 'tpDegC';
  end;// case LengthTemperature  }
end;// function GetTemperatureUnitFromStr  }

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetTemperatureUnit (TemperatureUnit:tTemperatureUnit);
begin
  fTankTemperatureUnit := TemperatureUnit;
end;// procedure SetTemperatureUnit

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetTemperatureUnitFromStr (TemperatureUnit:string);
begin
{  case TemperatureUnit of
    'tpDegF' : fTemperatureUnit := tpDegF;
    'tpDegC' : fTemperatureUnit := tpDegC;
  end;// case TemperatureUnit   }
end;// procedure SetTemperatureUnitFromStr

//========================================================================================
function TfrmTankData.GetVolumeUnit: tVolumeUnit;
begin
  Result := fTankVolumeUnit;
end;// function GetVolumeUnit

//----------------------------------------------------------------------------------------
function TfrmTankData.GetVolumeUnitStr: string;
begin
//  Result := 'Gallons';
  case VolumeUnit of
    tvGals : Result := 'tvGals';
    tvLitres : Result := 'tvLitres';
  end;// case Volume
end;// function GetVolumeUnitFromStr

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetVolumeUnit (VolumeUnit:tVolumeUnit);
begin
  fTankVolumeUnit := VolumeUnit;
end;// procedure SetVolumeUnit

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetVolumeUnitFromStr (VolumeUnit:string);
begin
{  case VolumeUnit of
    'tvGals' : fVolumeUnit := tvGals;
    'tvLiters' : fVolumeUnit := tvLiters;
  end;// case VolumeUnit  }
end;// procedure SetVolumeUnitFromStr

//========================================================================================
function TfrmTankData.GetTankWidth: real;
begin
  Result := fTankWidth;
end;// function GetTankWidth

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetTankWidth (TankWidth : real);
begin
  fTankWidth := TankWidth;
end;// procedure SetTankWidth

//========================================================================================
function TfrmTankData.GetTankDepth: real;
begin
  Result := fTankDepth;
end;// function GetTankDepth

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetTankDepth (TankDepth : real);
begin
  fTankDepth := TankDepth;
end;// procedure SetTankDepth

//========================================================================================
function TfrmTankData.GetTankHeight: real;
begin
  Result := fTankHeight;
end;// function GetTankHeight

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetTankHeight (TankHeight : real);
begin
  fTankHeight := TankHeight;
end;// procedure SetTankHeight

//========================================================================================
function TfrmTankData.GetTankVolume: real;
begin
  Result := fTankVolume;
end;// function GetTankVolume

//----------------------------------------------------------------------------------------
procedure TfrmTankData.SetTankVolume (TankVolume : real);
begin
  fTankVolume := TankVolume;
end;// procedure SetTankHeight

//========================================================================================
//          SUPPORT ROUTINES
//========================================================================================
function CalculateTankVolume : Real;
begin
  Result := 123.45;
end;// function CalculateTankVolume

//========================================================================================
//          MENU ROUTINES
//========================================================================================

//========================================================================================
//          FILE ROUTINES
//========================================================================================

//========================================================================================
//          COMMAND BUTTON ROUTINES
//========================================================================================
procedure TfrmTankData.bbtOKClick(Sender: TObject);
var
  vrlTReal : Real;
  vintErrorCode : Integer;
begin

  // First we validate all Data fields

  //----------
  // Tank Name
  //----------

  If Length(edtTankName.Text) < cbytMinTankNameLength then
  begin
    ErrorMessageDlgOk('Tank Name Error', '< 2 Characters');
    edtTankName.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// If Length() < cbytMinTankNameLength

  TankName := edtTankName.Text;

  //----------
  // Tank Width
  //----------

  // Ensure there is text in the text box
  if Length(edtWidth.Text) < 1 then
  begin
    ErrorMessageDlgOk('Tank Width Error', 'No Width value entered');
    edtWidth.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// if Length(edtWidth.Text) < 1

  // Ensure it is a valid numeric Real number
  try
    vrlTReal := StrToFloat(edtWidth.Text);
  except
    ErrorMessageDlgOk('Tank Width Error', 'Invalid Real Number');
    edtWidth.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;

  // Now ensure it is in the valid ranges
  case LengthUnit of
    tlInches : begin
                 if ( vrlTReal < cfltMinWidthValueInches ) or
                    ( vrlTReal > cfltMaxWidthValueInches ) then
                 begin
                   ErrorMessageDlgOk('Tank Width Error', 'Invalid Inches Value');
                   edtWidth.SetFocus;
                   ModalResult := mrNone;
                   Exit;
                 end;// if ( vrlTReal < cfltMinWidthValueInches )
               end;// tlInches
    tlCM : begin
                 if ( vrlTReal < cfltMinWidthValueCM ) or
                    ( vrlTReal > cfltMaxWidthValueCM ) then
                 begin
                   ErrorMessageDlgOk('Tank Width Error', 'Invalid CM Value');
                   edtWidth.SetFocus;
                   ModalResult := mrNone;
                   Exit;
                 end;// if ( vrlTReal < cfltMinWidthValueCM )
               end;// tlCM
  end;// case LengthUnit

  TankWidth := vrlTReal;

  //----------
  // Tank Depth
  //----------

  // Ensure there is text in the text box
  if Length(edtDepth.Text) < 1 then
  begin
    ErrorMessageDlgOk('Tank Depth Error', 'No Depth value entered');
    edtDepth.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// if Length(edtDepth.Text) < 1

  // Ensure it is a valid numeric Real number
  try
    vrlTReal := StrToFloat(edtDepth.Text);
  except
    ErrorMessageDlgOk('Tank Depth Error', 'Invalid Real Number');
    edtDepth.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;

  // Now ensure it is in the valid ranges
  case LengthUnit of
    tlInches : begin
                 if ( vrlTReal < cfltMinDepthValueInches ) or
                    ( vrlTReal > cfltMaxDepthValueInches ) then
                 begin
                   ErrorMessageDlgOk('Tank Depth Error', 'Invalid Inches Value');
                   edtDepth.SetFocus;
                   ModalResult := mrNone;
                   Exit;
                 end;// if ( vrlTReal < cfltMinDepthValueInches )
               end;// tlInches
    tlCM : begin
                 if ( vrlTReal < cfltMinDepthValueCM ) or
                    ( vrlTReal > cfltMaxDepthValueCM ) then
                 begin
                   ErrorMessageDlgOk('Tank Depth Error', 'Invalid CM Value');
                   edtDepth.SetFocus;
                   ModalResult := mrNone;
                   Exit;
                 end;// if ( vrlTReal < cfltMinDepthValueCM )
               end;// tlCM
  end;// case LengthUnit

  TankDepth := vrlTReal;

  //----------
  // Tank Height
  //----------

  // Ensure there is text in the text box
  if Length(edtHeight.Text) < 1 then
  begin
    ErrorMessageDlgOk('Tank Height Error', 'No Height value entered');
    edtHeight.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// if Length(edtHeight.Text) < 1

  // Ensure it is a valid numeric Real number
  try
    vrlTReal := StrToFloat(edtHeight.Text);
  except
    ErrorMessageDlgOk('Tank Height Error', 'Invalid Real Number');
    edtHeight.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;

  // Now ensure it is in the valid ranges
  case LengthUnit of
    tlInches : begin
                 if ( vrlTReal < cfltMinHeightValueInches ) or
                    ( vrlTReal > cfltMaxHeightValueInches ) then
                 begin
                   ErrorMessageDlgOk('Tank Heighth Error', 'Invalid Inches Value');
                   edtHeight.SetFocus;
                   ModalResult := mrNone;
                   Exit;
                 end;// if ( vrlTReal < cfltMinHeightValueInches )
               end;// tlInches
    tlCM : begin
                 if ( vrlTReal < cfltMinHeightValueCM ) or
                    ( vrlTReal > cfltMaxHeightValueCM ) then
                 begin
                   ErrorMessageDlgOk('Tank Height Error', 'Invalid CM Value');
                   edtHeight.SetFocus;
                   ModalResult := mrNone;
                   Exit;
                 end;// if ( vrlTReal < cfltMinHeightValueCM )
               end;// tlCM
  end;// case LengthUnit

  TankHeight := vrlTReal;

















{

  If Length(edtHeight.Text) < cbytMinHeightLength then
  begin
    ErrorMessageDlgOk('Tank Height Error', '< 2');
    edtHeight.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// If Length() < cbytMinHeightLength

  ValidRealStr (edtHeight.Text, vblnValidReal);

  if not vblnValidReal then
  begin
    ErrorMessageDlgOk('Tank Height Error', 'Invalid Real Number');
    edtHeight.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// if not vblnValidReal (edtHeight.Text)

  If Length(edtVolume.Text) < cbytMinVolumeLength then
  begin
    ErrorMessageDlgOk('Tank Volume Error', '< 2');
    edtVolume.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// If Length() < cbytMinVolumeLength

  ValidRealStr (edtVolume.Text, vblnValidReal);

  if not vblnValidReal then
  begin
    ErrorMessageDlgOk('Tank Volume Error', 'Invalid Real Number');
    edtVolume.SetFocus;
    ModalResult := mrNone;
    Exit;
  end;// if not vblnValidReal (edtVolume.Text) }

end;// procedure TfrmTankData.bbtOKClick

//========================================================================================
procedure TfrmTankData.bbtCancelClick(Sender: TObject);
begin
  //TankName :=
end;// procedure TfrmTankData.bbtCancelClick

//========================================================================================
procedure TfrmTankData.bbtHelpClick(Sender: TObject);
begin

end;// procedure TfrmTankData.bbtHelpClick

//========================================================================================

//========================================================================================
//          CONTROL ROUTINES
//========================================================================================

//========================================================================================
//          TOOLBAR ROUTINES
//========================================================================================

//========================================================================================
//           STATUSBAR ROUTINES
//========================================================================================

//========================================================================================
//          DATABASE ROUTINES
//========================================================================================

//=========================
//  OnChange Routines
//=========================

//=========================
//  OnClick Routines
//=========================

//=========================
//  OnKeypress Routines
//=========================
procedure TfrmTankData.edtTankNameKeyPress(Sender: TObject; var Key: char);
begin
  //  Since the Tank Name is used to create a Directory for the Tank data
  // we validate is as a Directory Name. We only allow a max Name Length
  // of cbytMaxTankNameLength
    Key := ValidDirectoryCharacter(Key);
end;// procedure TfrmTankData.edtNewTankKeyPress

//========================================================================================
procedure TfrmTankData.edtWidthKeyPress(Sender: TObject; var Key: char);
begin
  Key := ValidFloatCharacter(Key);
end;// procedure TfrmTankData.edtWidthKeyPress(Sender

//========================================================================================


//=========================
//  OnKeyUp Routines
//=========================

//========================================================================================
//          FORM ROUTINES
//========================================================================================
procedure TfrmTankData.FormCreate(Sender: TObject);
begin

  // Set the editbox Max string lengths
  edtTankName.MaxLength := cbytMaxTankNameLength;
  edtWidth.MaxLength := cbytMaxWidthLength;
  edtDepth.MaxLength := cbytMaxDepthLength;
  edtHeight.MaxLength := cbytMaxHeightLength;
  edtVolume.MaxLength := cbytMaxVolumeLength;

end;// procedure TfrmTankData.FormCreate

//========================================================================================
procedure TfrmTankData.FormShow(Sender: TObject);
var
  vbytTemp: byte;
begin

  // Set the Default Tankvalues
  fDefaultTankType := ttFOWLR;
  fDefaultLengthUnit := tlCM;
  fDefaultTemperatureUnit := tpDegF;
  fDefaultVolumeUnit := tvLitres;
{
  // Set the editbox text strings
  edtWidth.Text := FormatFloat(cstrWidthFormat, fTankWidth );
  edtDepth.Text := FormatFloat(cstrDepthFormat, fTankDepth );
  edtHeight.Text := FormatFloat(cstrHeightFormat, fTankHeight );
  edtVolume.Text := FormatFloat(cstrVolumeFormat, fTankVolume );
}
  // Set the ComboBox text strings
  for vbytTemp := 0 to 4 do
    cbxTankType.Items.Add(TankTypeArray[vbytTemp]);

  for vbytTemp := 0 to 1 do
    cbxLengthUnits.Items.Add(LengthUnitArray[vbytTemp]);

  for vbytTemp := 0 to 1 do
    cbxTemperatureUnits.Items.Add(TemperatureUnitArray[vbytTemp]);

  for vbytTemp := 0 to 1 do
    cbxVolumeUnits.Items.Add(VolumeUnitArray[vbytTemp]);

  SelectTankType;
  SelectLengthUnit;
  SelectTemperatureUnit;
  SelectVolumeUnit;
  CalculateTankVolume;

end;// procedure TfrmTankData.FormShow

//========================================================================================
procedure TfrmTankData.CreateNewTank;
begin

  frmTankData.Caption:='Create New Tank';
  TankType := DefaultTankType;
  fTankLengthUnit := DefaultLengthUnit;
  fTankTemperatureUnit := DefaultTemperatureUnit;
  fTankVolumeUnit := DefaultVolumeUnit;


  case fTankLengthUnit of
    tlInches : begin
                 stxWidth.Caption := stxWidth.Caption +
                                         LengthUnitArray[ord(tlInches)]+' :';
                 fTankWidth := cfltMinWidthValueInches;
                 stxDepth.Caption := stxDepth.Caption +
                                         LengthUnitArray[ord(tlInches)]+' :';
                 fTankDepth := cfltMinDepthValueInches;
                 stxHeight.Caption := stxHeight.Caption +
                                         LengthUnitArray[ord(tlInches)]+' :';
                 fTankHeight := cfltMinHeightValueInches;
               end;
    tlCM :
               begin
                 stxWidth.Caption := stxWidth.Caption +
                                         LengthUnitArray[ord(tlCM)]+' :';
                 fTankWidth := cfltMinWidthValueInches;
                 stxDepth.Caption := stxDepth.Caption +
                                         LengthUnitArray[ord(tlCM)]+' :';
                 fTankDepth := cfltMinDepthValueInches;
                 stxHeight.Caption := stxHeight.Caption +
                                         LengthUnitArray[ord(tlCM)]+' :';
                 fTankHeight := cfltMinHeightValueInches;
               end;
  end;// case fLengthUnit of

  case fTankVolumeUnit of
    tvGals : stxVolume.Caption := stxVolume.Caption +
                                  VolumeUnitArray[ord(tvGals)]+' :';
    tvLitres : stxHeight.Caption := stxHeight.Caption +
                                    VolumeUnitArray[ord(tvLitres)]+' :';
  end;// case fTankVolumeUnit of

  frmTankData.ShowModal;

end;// procedure TfrmTankData.CreateNewTank;

//========================================================================================
end.// unit TankData

